package com.yzly.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.yzly.demo.service.demo.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;

@RestController
@Validated
@Api(value = "TestController", description = "测试demo相关AIP", tags = "TestController")
public class TestController {


    @Inject
    private TestService testService;


    @GetMapping("/getTestJson")
    @ApiOperation(value = "获取测试数据", httpMethod = "GET")
    public JSONObject getTestJson(Integer id) {
        return testService.getTestJson(id);
    }

    @GetMapping("/cleanCache")
    @ApiOperation(value = "清除缓存", httpMethod = "GET")
    public String cleanCache() {
        testService.cleanCache();
        return "ok";
    }

    @PostMapping("/testPost")
    @ApiOperation(value = "测试post请求", httpMethod = "POST")
    public String testPost(int id, String name) {
        System.out.println("请求到了");
        return "ok";
    }
}
